package com.serli.sample.data.runner.domain;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


@SuppressWarnings("serial")
@Entity
@Table(name = "CIRCUIT")
@NamedQueries({
    @NamedQuery(name = Trip.QUERY_FIND_ALL_ORDER_BY_NAME, query = "SELECT OBJECT(t) FROM Trip t ORDER BY t.name"),
    @NamedQuery(name = Trip.QUERY_FIND_BY_NAME, query =  "SELECT OBJECT(t) FROM Trip t WHERE t.name = :name")
})
public class Trip implements Serializable {
	
    public static final String QUERY_FIND_ALL_ORDER_BY_NAME = "findAllOrderByName";
    public static final String QUERY_FIND_BY_NAME = "findByName";
	public static final String PARAMETER_NAME = "name";
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID_CIRCUIT")
	private long id;
	
	@Basic
	@Column(name = "NOM", length = 32)
	private String name;
	
	@Basic
	@Column(name = "DISTANCE", columnDefinition="DECIMAL(6,2)")
	private float distance;
	
	@Basic
	@Column(name = "NOTE", length = 8192)// 8 Kio
	private String note;

	@Basic
	@Column(name = "DEPARTEMENT", length = 10)
	private String  postalCode;
	
	@Basic
	@Column(name = "VILLE", length = 32)
	private String city;
	
	@Lob
	@Basic(fetch=FetchType.LAZY)
	@Column(name = "IMAGE", length = 16777216)// 16 Mio = 16*2^20
	private byte[] byteImage;
	
	@Basic
	@Column(name = "CHEMIN_FICHIER_IMAGE", length = 512)
	private String imageUrl;

	public long getId() {
		return id;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String value) {
		name = value;
	}
	
	public float getDistance() {
		return distance;
	}

	public void setDistance(float distance) {
		this.distance = distance;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public String getPostalCode() {
		return postalCode;
	}

	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}
	
	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public byte[] getByteImage() {
		return byteImage;
	}

	public void setByteImage(byte[] byteImage) {
		this.byteImage = byteImage;
	}
}
